package com.itheima.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.entity.PageResult;
import com.itheima.entity.QueryPageBean;
import com.itheima.entity.Result;
import com.itheima.service.MenuService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/Menu")
public class MenuController {

    @Reference
    private MenuService menuService;
    @RequestMapping("/findPage")
    public PageResult findPage(@RequestBody QueryPageBean queryPageBean){
        return menuService.findByPage(queryPageBean);
    }
    @RequestMapping("/findAllMenu")
    public Result findAllMenu(){
        return menuService.findAllMenu();
    }
    @RequestMapping("/add")
    public Result add(@RequestBody Map map){
        return menuService.add(map);
    }

    @RequestMapping("/findById")
    public Result findById(Integer id){
            Map map =  menuService.findById(id);
            return new Result(true,null,map);
    }
   @RequestMapping("/edit")
    public Result edit(@RequestBody Map map){
       System.out.println(map);
       return menuService.edit(map);
   }
    @RequestMapping("/delete")
    public Result delete(int id){

        return menuService.delete(id);
    }
}
